package com.itheima.xml;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;



import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Scanner;

public class DemoXml {
    public static void main(String[] args) throws Exception {
        //获取路径
        String path = DemoXml.class.getClassLoader().getResource("beans.xml").getPath();
        //解析XML
        Document document= (Document) Jsoup.parse(new File(path),"UTF-8");
        //获取控制台输入路径
        Scanner scanner = new Scanner(System.in);
        String url = scanner.nextLine();

        Element ele_servlet = (Element) document.getElementsByAttributeValue("url", url).get(0);
        String className = ele_servlet.attr("class");


        Class clazz = Class.forName(className);
        Object obj = clazz.newInstance();


        Method method = clazz.getMethod("service");

        method.invoke(obj);



    }
}
